// 自定义国际化配置
import { createI18n } from 'vue-i18n';

import zh_CN from '@/lang/zh_CN';
import en_US from '@/lang/en_US';

/**
 * 获取当前语言
 * @returns zh-cn|en ...
 */
export const getLanguage = () => {
	const language = useStorage('language', 'zh_CN');
	if (language.value) {
		return language.value;
	}
	return 'zh_CN';
};

const i18n = createI18n({
	globalInjection: true,
	allowComposition: true,
	legacy: false,
	locale: getLanguage(),
	messages: {
		zh_CN: zh_CN,
		en_US: en_US
	}
});

export default i18n;

